import request from '@/utils/request';
const api_name = '/comment';

export default {
  // 通过id获取评论
  getCommentById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'get'
    });
  },
  // 根据条件查询评论(分页)
  getCommentListByPage(page, limit, searchObj) {
    return request({
      url: `${api_name}/${page}/${limit}`,
      method: 'post',
      data: searchObj
    });
  },
  // 根据ID删除一个评论
  removeCommentById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'delete'
    });
  },
  // 新增一个评论
  saveComment(comment) {
    return request({
      url: `${api_name}/`,
      method: 'post',
      data: comment
    });
  },
  // 修改一个评论
  updateComment(comment) {
    return request({
      url: `${api_name}/${comment.commentId}`,
      method: 'put',
      data: comment
    });
  }
};
